using System;
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web;

namespace DreamBuilder.UI.UserControls
{
	public class ListTemplateImageButton :ControlBase, ITemplate
	{
		private string imageUrlStr = "" ;
		private string commandNameStr = "" ;
		private string idStr = "" ;
        private string commandArgumentStr = "";

		public ListTemplateImageButton()
		{}
		public ListTemplateImageButton(string sImageUrl)
		{
			imageUrlStr = sImageUrl ;
		}
		
		public ListTemplateImageButton(string sImageUrl,string sCommandName)
		{
			imageUrlStr = sImageUrl ;
			commandNameStr = sCommandName ;
		}

        public ListTemplateImageButton(string sImageUrl, string sCommandName, string sID)
		{
			imageUrlStr = sImageUrl ;
			commandNameStr = sCommandName ;
			idStr = sID ;
		}

        public ListTemplateImageButton(string sImageUrl, string sCommandName, string sID, string commandargument)
        {
            imageUrlStr = sImageUrl;
            commandNameStr = sCommandName;
            idStr = sID;
            commandArgumentStr = commandargument;
        }

		public void InstantiateIn(Control container)
		{			
			System.Web.UI.WebControls.ImageButton imgBtn = new System.Web.UI.WebControls.ImageButton() ;
            
			if(!string.IsNullOrEmpty(imageUrlStr))
			{
				imgBtn.ImageUrl = imageUrlStr ;
			}
			if(!string.IsNullOrEmpty(commandNameStr))
			{
				imgBtn.CommandName = commandNameStr ;
			}
			if(!string.IsNullOrEmpty(idStr ))
			{
				imgBtn.ID = idStr ;
			}
            if (!string.IsNullOrEmpty(commandArgumentStr))
            {
                imgBtn.CommandArgument = commandArgumentStr;
            }
			ControlPath = "UserControls/UCList";
			if (commandNameStr=="Delete"){imgBtn.Attributes.Add("onClick","return confirm('"+GetString("ControlListDeletePrompt")+"');");}
			if (commandNameStr=="Approve"){imgBtn.Attributes.Add("onClick","return confirm('"+GetString("ControlListConfirmPrompt")+"');");}
			container.Controls.Add(imgBtn);
		}
	}
}
